﻿var EditBoxID = "editBox";

function InitEdit() {
    InitEditBox(EditBoxID);
}
function InitEditBox(editBoxID) {
    for (var input in HTMLInputTypes) {
        if (typeof HTMLInputTypes[input] != 'function')
            InitInput(editBoxID, HTMLInputTypes[input]);
    }
}
function InitInput(containerId, markName) {
    $("#" + containerId).find(markName).each(function () {
        var inp = $(this);
        if (inp.attr("unq") != null && inp.val() != null && inp.val() != '') {
            inp.attr("olddata", inp.val());
        }
        $(this).blur(function () {
            async = true;
            Validate($(this));
        });
    });
}

function OnEditSubmit() {
    async = false;
    var result = true;
    if (typeof OnSubmitingExtend != 'undefined')
        OnSubmitingExtend();
    result = ValidateInContainer(EditBoxID, function () {
        result = false;
    }, false);
    if (result) {
        if (typeof OnSubmitValidateExtend != 'undefined')
            result = OnSubmitValidateExtend();
        if (typeof OnSubmitExtend != 'undefined')
            OnSubmitExtend();
    }
    return result;
}

$().ready(function () {
    InitEdit();
    if (typeof InitEditEx != 'undefined')
        InitEditEx();
    if (typeof InitEditExII != 'undefined')
        InitEditExII();
});